package com.ssy.lingxi.marketing.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 商家优惠券类型枚举
 * @author yzc
 * @version 2.0.0
 * @date 2021/6/28
 */
public enum MerchantCouponEffectiveTypeEnum {

    /**
     * 固定有效时间 - 1
     */
    FIXED(1, "固定有效时间"),

    /**
     * 自领取开始时间 - 2
     */
    SELF(2, "自领取开始时间"),
    ;

    private final Integer code;
    private final String message;

    MerchantCouponEffectiveTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getCodeMessage(Integer code) {
        MerchantCouponEffectiveTypeEnum status = Arrays.stream(MerchantCouponEffectiveTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return status == null ? "未知" : status.getMessage();
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

}